<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>订单要求</title>
    <th:block th:include="base::header"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form method="post" class="layui-form" lay-filter="form">
            <div class="layui-form-item" >
                <div class="layui-inline">
                    <input id="id" name="id" style="display: none;"></input>
                </div>
            </div>
            <div class="layui-form-item" >
                <label for="note" class="layui-form-label">订单要求
                </label>
                <div class="layui-inline">
                    <textarea id="note" name="note" lay-verify="note" style="display: none;"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label  class="layui-form-label"></label>
                <button class="layui-btn" lay-submit lay-filter="add">提交</button>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    var basePath ='[[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]]';
    var orderId=[[${id}]]

    layui.use(
        ['form', 'layer','jquery','layedit','util','laydate'],
        function() {
            $ = layui.jquery;
            var form = layui.form;
            var layer = layui.layer;
            var layedit=layui.layedit;

            $.get("loadedit",{"id":orderId},function(order){
                form.val("form", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                    "id": order.orderId,
                    "note": order.note
                });
                var index=layedit.build('note',{
                    height: 400,
                    uploadImage: {url: 'img', type: 'post'}
                });//编辑器

                form.verify({
                    note: function (value) {
                        layedit.sync(index);
                    }
                });
            });

            //监听提交
            form.on('submit(add)',function(data) {
                /*var time=util.toDateString(new Date().getTime(), "yyyy-MM-dd HH:mm:ss");
                data.field.addTime=time;
                data.field.reviseTime=time;*/

                console.log(data.field);
                //发异步，把数据提交给php
                $.post("requirement",data.field,function(res){
                    if(res.code==200){
                        layer.alert(res.msg,{
                            icon:1,
                        },function(){
                            //关闭当前frame
                            xadmin.close();
                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });
                    }
                });
                //发异步，把数据提交给php
                return false;
            });
        });

</script>
</body>
</html>
